<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="redis" uri="http://www.shopjsp.com/redisTag/functions" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="basePath" value="${redis:getSysConfig('base_path_back')}"/>
<script type="text/javascript">
    /**
     * 更改有效状态
     */
    <shiro:hasPermission name="back_gotoFansGroupPage_updateState">
    function changeFansGroupState(){
        /**获取选中行的id**/
        var selectedRow= $("#tt").bootstrapTable('getSelections');
        if(selectedRow.length==1){
            $("#btn_change").attr("data-target","#changeFansGroupStateModal");/**选中了记录后才可打开对应的模态框**/
            /**隐藏域**/
            $("#c_fansGroupId").val(selectedRow[0].fansGroupId);
            /**可见表单控件**/
            if (selectedRow[0].isValid==0){/**是否有效 0、有效  1、无效**/
                $("#isValid_1").attr("checked","checked");
            }else if (selectedRow[0].isValid==1){
                $("#isValid_2").attr("checked","checked");
            }
        }else{
            $("#btn_change").attr("data-target","");/**没有选中记录不可打开模态框**/
            showMsg("请选择一行记录！");
        }
    }
    </shiro:hasPermission>

    /**
     * 表单异步提交
     */
    function submitChangeFansGroupStateForm(){
        var options = {
            url: $("#changeFansGroupStateForm").attr("action"),
            type : "post",
            dataType:"json",
            success : function(data) {
                if(data.success==true){
                    /** 先重置查询框的值**/
                    resetQueryForm();
                    /** 重新刷新列表数据**/
                    $("#tt").bootstrapTable('refresh');
                    /** 自动关闭弹出模态框窗口**/
                    $(".close").click();
                    showMsg("保存成功！");
                }else{
                    showMsg("保存失败！");
                }
            }
        };
        $("#changeFansGroupStateForm").ajaxSubmit(options);
    }
</script>

<!--更改有效状态模态框（Modal） -->
<div class="modal fade" id="changeFansGroupStateModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog" style="width:70%">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h5 class="modal-title" id="myModalLabel">更改有效状态</h5>
            </div>
            <div class="modal-body">
                <form id="changeFansGroupStateForm"  method="post" action="${basePath}/back/wx/fansGroup/changeFansGroupState.sjson">
                    <input id="c_fansGroupId" type="hidden" name="fansGroupId" noclear="true"/>
                    <table align="center" class="addOrEditTable table-bordered table" style="width:100%;">
                        <tr>
                            <td class="toright_td" width="150px"><span style="color:red">* </span>是否有效:&nbsp;&nbsp;</td>
                            <td  class="toleft_td">
                                <label class="checkbox-inline">
                                    <input type="radio" name="isValid" id="isValid_1" class="radioInput" value="0" checked="checked">&nbsp;有效
                                </label>
                                <label class="checkbox-inline">
                                    <input type="radio" name="isValid" id="isValid_2" class="radioInput" value="1"  >&nbsp;无效
                                </label>
                            </td>
                        </tr>
                    </table>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" id="validateBtn" class="btn btn-primary"  onclick="submitChangeFansGroupStateForm()">保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>